/**
 * @cls app.module.UserManage
 * @jss module/sys/user-manage.js
 */
(function(){
    var ns = Ext.ns("app.module.UserManage");
    Ext.apply(ns, {
        init: function(id){
            var sm = new Ext.grid.CheckboxSelectionModel();
            var panel = new Ext.grid.GridPanel({
                id: id,
                title: '用户管理',
                width: 400,
                closable: true,
                columnLines: true,
                store: new Ext.data.JsonStore({
                    autoDestroy: true,
                    url: 'data/data-user-manage.json',
                    root: 'ds',
                    autoLoad: true,
                    idProperty: 'id',
                    fields: ['username', 'name', 'status', 'createTime', 'updateTime']
                }),
                sm: sm,
                tbar: {
                    xtype: 'toolbar',
                    items: [{
                        xtype: 'button',
                        text: '新增',
                        icon: 'images/add-user.png'
                    }, '-', {
                        xtype: 'button',
                        text: '修改',
                        icon: 'images/user.png'
                    }, '-', {
                        xtype: 'button',
                        text: '删除',
                        icon: 'images/del-user.png'
                    }, '-', {
                        xtype: 'button',
                        text: '重置密码',
                        icon: 'images/reset-task.gif'
                    }, '-', {
                        xtype: 'button',
                        text: '启用',
                        icon: 'images/start-task.gif'
                    }, {
                        xtype: 'button',
                        text: '停用',
                        icon: 'images/stop-task.gif'
                    }, '-', {
                        xtype: 'button',
                        text: '刷新',
                        icon: 'extjs/resources/images/default/grid/refresh.gif'
                    }, '->', {
                        xtype: 'textfield'
                    }]
                },
                columns: [sm, new Ext.grid.RowNumberer(), {
                    xtype: 'gridcolumn',
                    header: '用户名',
                    sortable: true,
                    dataIndex: 'username',
                    width: 120
                }, {
                    xtype: 'gridcolumn',
                    header: '真实姓名 ',
                    sortable: true,
                    dataIndex: 'name',
                    width: 120
                }, {
                    xtype: 'gridcolumn',
                    header: '状态',
                    sortable: true,
                    dataIndex: 'status',
                    width: 100,
                    renderer: function(v){
                        return '<span style="' + (v ? 'color:#0000FF;">启用' : 'color:#FF0000;">停用') + '<span>';
                    }
                }, {
                    xtype: 'gridcolumn',
                    header: '创建时间',
                    sortable: true,
                    dataIndex: 'createTime',
                    width: 140
                }, {
                    xtype: 'gridcolumn',
                    header: '修改时间',
                    sortable: true,
                    dataIndex: 'updateTime',
                    width: 140
                }]
            });
            return panel;
        }
    });
})();
